package com.ruoyi.gateway.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.gateway.service.ValidateCodeService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 验证码处理
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/validateCode")
public class ValidateCodeController {

    private final ValidateCodeService validateCodeService;

    /**
     * 生成验证码
     */
    @GetMapping("/createCaptcha")
    public R<Map<String, Object>> createCaptcha() {
        R<Map<String, Object>> captcha = null;
        try {
            captcha = validateCodeService.createCaptcha();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return captcha;
    }

}
